package com.diandian.backend.store.param;

import com.diandian.backend.store.constants.DianDianStoreConstant;
import com.diandian.backend.store.dto.StoreElemeRetailStoreTreeUpdateByIdParamDTO;
import com.diandian.base.boot.starter.exception.DefaultException;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.io.Serializable;
import java.util.Date;

public class StoreElemeRetailStoreTreeUpdateByIdParam implements Serializable {

	private Long id;
	private String type;
	private String nodeName;
	private String nodeParam;
	private String remark;
	private String updateUserId;
	private String updateUserName;
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date updateTime;

	public void check(){
		if(id == null){
			throw new DefaultException("id不能为空");
		}
		if(this.type == null || "".equals(this.type)){
			throw new DefaultException("类型不能为空");
		}
		if(DianDianStoreConstant.ELEME_RETAIL_TREE_NODE_TYPE_SERIES.equals(this.type) && (this.nodeParam == null || "".equals(this.nodeParam))){
			throw new DefaultException("类型为连锁时，连锁ID不能为空");
		}
		if(updateTime == null){
			updateTime = new Date();
		}
	}

	public StoreElemeRetailStoreTreeUpdateByIdParamDTO toDTO(){
		StoreElemeRetailStoreTreeUpdateByIdParamDTO dto = new StoreElemeRetailStoreTreeUpdateByIdParamDTO();
		dto.setId(this.id);
		dto.setType(this.type);
		dto.setNodeName(this.nodeName);
		dto.setNodeParam(this.nodeParam);
		dto.setRemark(this.remark);
		dto.setUpdateUserId(this.updateUserId);
		dto.setUpdateUserName(this.updateUserName);
		dto.setUpdateTime(this.updateTime);
		return dto;
	}

	public Long getId() {
		return id;
	}
	public Long setId(Long id) {
		return this.id = id;
	}
	public String getType() {
		return type;
	}
	public String setType(String type) {
		return this.type = type;
	}
	public String getNodeName() {
		return nodeName;
	}
	public String setNodeName(String nodeName) {
		return this.nodeName = nodeName;
	}
	public String getRemark() {
		return remark;
	}
	public String setRemark(String remark) {
		return this.remark = remark;
	}
	public String getUpdateUserId() {
		return updateUserId;
	}
	public String setUpdateUserId(String updateUserId) {
		return this.updateUserId = updateUserId;
	}
	public String getUpdateUserName() {
		return updateUserName;
	}
	public String setUpdateUserName(String updateUserName) {
		return this.updateUserName = updateUserName;
	}
	public Date getUpdateTime() {
		return updateTime;
	}
	public Date setUpdateTime(Date updateTime) {
		return this.updateTime = updateTime;
	}

	public String getNodeParam() {
		return nodeParam;
	}

	public void setNodeParam(String nodeParam) {
		this.nodeParam = nodeParam;
	}
}
